package com.taldh.algorithm.treenode;

import com.taldh.algorithm.base.TreeNode;

public class MirrorTree {

    public TreeNode mirrorTree(TreeNode root) {
        if (root == null) {
            return root;
        }
        TreeNode treeNode = root.left;
        root.left = root.right;
        root.right = treeNode;
        if (root.left != null) {
            mirrorTree(root.left);
        }
        if (root.right != null) {
            mirrorTree(root.right);
        }
        return root;
    }

}